
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as io;
import 'package:shelf_static/shelf_static.dart';

void main() async {
  // 定义静态资源的目录（如 "web" 文件夹）
  var handler = createStaticHandler('static',
      defaultDocument: 'index.html', listDirectories: true);

  // 将请求记录到控制台的中间件
  var pipeline = const Pipeline().addMiddleware(logRequests()).addHandler(handler);

  // 启动服务器
  var server = await io.serve(pipeline, 'localhost', 3000);
  print('静态资源服务器运行在 http://${server.address.host}:${server.port}');
}
